package com.itheima.stock.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.stock.mapper.SysLogMapper;
import com.itheima.stock.pojo.entity.SysLog;
import com.itheima.stock.pojo.vo.req.PageResult;
import com.itheima.stock.pojo.vo.req.Plog;
import com.itheima.stock.pojo.vo.resp.R;
import com.itheima.stock.pojo.vo.resp.ResponseCode;
import com.itheima.stock.service.LogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogsServiceImpl implements LogsService {

    @Autowired
    private SysLogMapper sysLogMapper;
    @Override
    public R<PageResult<SysLog>> PageLogs(Plog plog) {

        PageHelper.startPage(plog.getPageNum(),plog.getPageSize());
        List<SysLog> sysLogs = sysLogMapper.getLogs(plog);
        PageResult<SysLog> result = new PageResult<>(new PageInfo<>(sysLogs));
        return R.ok(result);
    }
    @Override
    public R<ResponseCode> delLog(List<Long> logIds) {
        sysLogMapper.deleteByIds(logIds);

        return R.ok(ResponseCode.SUCCESS);
    }
}
